<!DOCTYPE HTML>
<html>
<head>
    <title>失联登记</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .hideBorder{
        border: solid 0px;
    }
    .form-table{
        width: 100%;
    }
</style>
<body>
<div class="mini-fit" style="margin-bottom: 40px">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <form id="form1" method="post" style="margin-top: 10px;">
            <div id="editform" class="form" >
                <table class="form-table" align="center" cellspacing="8">
                    <tr>
                        <td width="100" align="right"><font color="#dc143c">*</font>姓&emsp;&emsp;名:</td>
                        <td >
                            <div property="editor" id="queryName" class="mini-autocomplete" required="true" style="width:100%;" valueField="id" textField="name"
                                 url="/azbj/bjdxInfo/slrygl/toSldj/getBaseInfoList" showColumns="false"  onvaluechanged="getQueryName()" popupEmptyText="未查询到值">
                                <div property="columns">
                                    <div field="name"  ></div>
                                    <div field="hjd" ></div>
                                    <div field="idnum" ></div>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form2" method="post">
            <div id="editform" class="form" >
                <table class="form-table" align="center" cellspacing="8">
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">姓&emsp;&emsp;名:</span></td>
                        <td >
                            <input id="name" name="name"  class="mini-textbox" borderStyle="border:0;" style="width: 100%;"  readonly />
                        </td>
                    </tr>
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">性&emsp;&emsp;别:</span></td>
                        <td>
                            <input id="sex"  name="sex"  class="mini-textbox" borderStyle="border:0" style="width: 100%;color: #8B8B8B"  readonly />
                        </td>
                    </tr>
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">身份证号:</span></td>
                        <td >
                            <input id="idnum"  name="idnum"  class="mini-textbox" borderStyle="border:0" style="width:100%;color: #8B8B8B"  readonly />
                        </td>
                    </tr>
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">出生日期:</span></td>
                        <td >
                            <input id="age"  name="age" class="mini-textbox" borderStyle="border:0"  style="width: 100%;color: #8B8B8B"  readonly/>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">户籍地址:</span></td>
                        <td>
                            <input id="hujidi"  name="hujidi" class="mini-textbox" borderStyle="border:0" style="width: 100%;color: #8B8B8B" readonly/>
                        </td>
                    </tr>
                    <tr>
                        <td width="100" align="right"><span style="color: #8B8B8B">居住地址:</span></td>
                        <td>
                            <input id="juzhudi"  name="juzhudi" class="mini-textbox" borderStyle="border:0" style="width: 100%;color: #8B8B8B" readonly />
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <form id="form3" method="post" >
            <div id="editform" class="form" >
                <#--罪犯编号-->
                <input id="priNum" name="priNum" class="mini-hidden"/>
                <table class="form-table" align="center" cellspacing="8">
                    <#if "${localCode!''}" == "140000">
                        <tr>
                            <td width="100" align="right"><font color="#dc143c">*</font>人户分离时间:</td>
                            <td>
                                <input id="dateTuoguan" name="dateTuoguan" allowInput="true" class="mini-datepicker" style="width: 100%;"
                                       required="true" ondrawdate="onDrawDate" />
                            </td>
                        </tr>
                    <#else>
                        <tr>
                            <td width="100" align="right"><font color="#dc143c">*</font>失联时间:</td>
                            <td>
                                <input id="dateTuoguan" name="dateTuoguan" allowInput="false" class="mini-datepicker" style="width: 100%;"
                                       required="true" ondrawdate="onDrawDate" />
                            </td>
                        </tr>
                    </#if>

                    <#if "${localCode!''}" == "140000">
                    <#else>
                        <tr>
                            <td width="100" align="right"><font color="#dc143c">*</font>失联原因:</td>
                            <td >
                                <input id="reason"  name="reason" class="mini-textarea" style="width: 100%;height: 80px;" required="true"/>
                            </td>
                        </tr>
                    </#if>
                </table>
            </div>
        </form>
    </div>
</div>
<div  style="position: absolute;bottom: 0;line-height:40px;width: 100%;border-top:1px solid #dfdfdf;text-align: center">
    <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">保存</a>
    <a class="mini-button" iconCls="fa-undo" plain="true" onclick="close('cancel')">取消</a>
</div>

<script type="text/javascript">
    mini.parse();
    var form2 = new mini.Form("form2");
    var form3 = new mini.Form("form3");
    var queryNameObj = mini.get("queryName");
    var flag = false;

    function saveData(){
        form3.validate();
        if (form3.isValid() == false) {
            return;
        }

        if(flag===false){
            mini.alert("请输入正确姓名");
            return;
        }
        var data = form3.getData();
        var priNum = queryNameObj.getValue();
        //代表失联，后台必须字段
        data.isTuoguan = '1';
        data.priNum = priNum;
        data.pridepartnum = priNum;
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/bjdxInfo/qbrygl/bjdxSldjSave",
            type: "post",
            data: {data: json},
            success: function (success) {
                mini.alert("保存成功","成功",window.CloseOwnerWindow);
            }
        });
    }

    function getQueryName(){
        var priNum = queryNameObj.getValue();
        $.ajax({
            url: "/azbj/bjdxInfo/qbrygl/query/getInfo?priNum="+priNum,
            type: "post",
            success: function (result) {
                var info = result.data;
                var data={};
                data.name=info.pname;
                if(info.sex==0){
                    data.sex="未知的性别";
                }else if(info.sex==1){
                    data.sex="男性";
                }else if(info.sex==2){
                    data.sex="女性";
                }else {
                    data.sex="未说明的性别";
                }
                data.idnum =info.idnum;
                data.age = info.nl;
                var hujidi = "";
                if(info.nativeproName){
                    hujidi+=info.nativeproName;
                }
                if(info.nativecityName){
                    hujidi+=info.nativecityName;
                }
                if(info.nativecouName){
                    hujidi+=info.nativecouName;
                }
                if(info.nativevillName){
                    hujidi+=info.nativevillName;
                }
                if(info.nativenum){
                    hujidi+=info.nativenum;
                }
                data.hujidi = hujidi;
                var juzhudi ="";
                if(info.placeproName){
                    juzhudi+=info.placeproName;
                }
                if(info.placecityName){
                    juzhudi+=info.placecityName;
                }
                if(info.placecouName){
                    juzhudi+=info.placecouName;
                }
                if(info.placevillName){
                    juzhudi+=info.placevillName;
                }
                if(info.placenum){
                    juzhudi+=info.placenum;
                }
                data.juzhudi = juzhudi;
                form2.setData(data);
                flag = true;
            }
        });
    }

    //失联时间不能选择比今天靠后的日期
    function onDrawDate(e) {
        var date = e.date;
        var d = new Date();
        //选择的日期大于今天日期 不能选
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
    }

    function close(action){
        if(window.CloseOwnerWindow){
            window.CloseOwnerWindow(action);
        }else{
            window.close();
        }
    }
</script>
</body>
</html>